<script>
	import {
		mapState,
		mapMutations
	} from "vuex";
	import {
		getInfo
	} from "@/business/systeminfo.js";
	import {
		checkUpdateVersion
	} from "@/business/updateManager.js";
	import {
		timer
	} from "@/utils/timer.js"
	export default {
		globalData: {
			couponTime: 5 * 60 * 1000,
			endTime: 0,
			frequency: 2,
			keyer: null,
			Payios:1,
		},
		onLaunch: function() {
			let config = {
				interval: 1, //间隔天数，间隔为整数
				runNow: false, //是否立即运行
				time: "23:59:00" //执行的时间点 时在0~23之间
			}
			console.log("App Launch");
			timer(config, this.func)
			checkUpdateVersion();
			// let initialTime = 5 * 60 * 1000;
			// uni.setStorageSync("couponTime", initialTime);
			if (!wx.getStorageSync("baseinfopro").openid) {
				getInfo();
			}
			this.getAccessToken()
		},
		onShow: function() {
			console.log("App Show");
		},
		onHide: function() {
			console.log("App Hide");
		},
		methods: {
			func() {
				uni.setStorageSync('frequency', 3)
			},
			getAccessToken() {
				uni.request({
					url: 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=CWIZRKYuYCdxaxpRY4IAS8l3&client_secret=pFsZMSGpas1cezGfiddi0AwZxMU9vmaG',
					method: "POST",
					success(res) {
						console.log(res, 'getAccessToken');
						getApp().globalData.accessToken = res.data.access_token
					}
				})
			}
		}
	};
</script>

<style lang="scss">
	/*每个页面公共css */
	/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
	@import "@/uni_modules/uview-ui/index.scss";
</style>
